package com.lx.regex;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.logging.SimpleFormatter;

public class datedemo01 {
    public static void main(String[] args) throws ParseException {
//        method();
//        method2();
//        method3();
        method4();
    }

    //注意parse和format的区别
    private static void method4() throws ParseException {
        String str = "2000年11月11日";
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy年MM月dd日");
        Date date = sdf.parse(str);
        SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy年MM月dd日");
        String s = sdf.format(date);
        System.out.println(s);
    }

    private static void method3() throws ParseException {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        String str = "2000-11-11";
        Date date = sdf.parse(str);
        SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy年MM月dd日");
        String result = sdf2.format(date);
        System.out.println(result);
    }

    private static void method2() throws ParseException {
        String str = "2023-11-11 11:11:11";
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        Date date = sdf.parse(str);
        System.out.println(date);
    }

    private static void method() {
        SimpleDateFormat sdf = new SimpleDateFormat();
        Date d = new Date(0L);
        String date = sdf.format(d);
        System.out.println(date);

        SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy年MM月dd日 HH:mm:ss EE");
        String str = sdf2.format(d);
        System.out.println(str);
    }
}
